<template>
  <div>
    <MyEcharts :option="option" />
  </div>
</template>
<script>
import { openApiStatisticalDataQueryResourceMap } from "@/api/admin/data/data";
export default {
  components: {
    MyEcharts: () => import("@/components/myEcharts/index.vue"),
  },
  data() {
    return {
      listQuery: {
        deptType: 1, //单位类型；1-校区，2-系，3-教研室
        selection: 0, //是否精选课程，1-是，0-否
        sourceUnit: "", //单位
      },
      option: null,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      openApiStatisticalDataQueryResourceMap(this.listQuery).then((res) => {
        let { data } = res.data;
        this.initEcharts(data);
      });
    },
    initEcharts(data) {
      // 饼图
      this.option = {
        xAxis: {
          type: "category",
          data: data.map((v) => v.name),
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: data.map((v) => v.value),
            type: "line",
          },
        ],
      };
    },
  },
};
</script>